#include <iostream>
#define LL long long
using namespace std;

const int kMaxN = 5010;

int a[kMaxN];
LL sum[kMaxN], work[kMaxN];
LL f[kMaxN];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
    work[i] = sum[i >> 1] + sum[i - (i >> 1)];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < i; j++) {
      f[i] = max(f[i], f[i - j - 1] + work[j]);
    }
  }
  cout << f[n] << "\n";
  return 0;
}
